package com.vhdadw.strategy;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class ShardingTableConfig {

    //启用存储数据库位置编号
    private static final List<String> tablePrefixList = new ArrayList<>();

    private static Random random = new Random();

    //配置启用哪些表的前缀
    static{
        tablePrefixList.add("0");
        tablePrefixList.add("a");
    }

   public static String getRandomTablePrefix(String code){

       int hashCode = code.hashCode();

       int index =  Math.abs(hashCode) % tablePrefixList.size();

       return tablePrefixList.get(index);
   }
}
